<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
<head>
	<title>Simpla CMS</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
	<meta http-equiv="Content-Language" content="ru" />
</head>
<body>

<?php

if(isset($_GET['domains']) || isset($_POST['domains']))
{
	if(!empty($_POST['domains']))
		$domains = preg_split("/[\s,]+/", $_POST['domains']);
	else
		$domains = preg_split("/[\s,]+/", $_GET['domains']);	
	foreach($domains as $domain)
	{
		$domain = strtolower($domain);
		$domain = preg_replace('/http\:\/\//ui', '', $domain);
		$domain = preg_replace('/[^0-9a-z\-\. ]/ui', '', $domain);
		$domain = preg_replace('/[ ]+/ui', ' ', $domain);
		$domain = preg_replace('/^www./ui', '', $domain);
		$domain = preg_replace('/ www./ui', ' ', $domain);
		
		if(preg_match('/[^.]+\.[^.]+$/', $domain))
		{
		
			$valid = false;
			$validdomains = file('valid.txt');
	
			foreach($validdomains as $d)
			if(strtolower($domain)==strtolower(trim($d)))
				$valid=true;
			
			$todo = false;
			$tododomains = file('todo.txt');
	
			foreach($tododomains as $d)
			if(strtolower($domain)==strtolower(trim($d)))
				$todo=true;
			
			if(!$valid && !$todo)
			{
				$f = fopen('todo.txt','a');
				fwrite($f, $domain."\r\n");
				fclose($f);
			}	
			if($valid)
				print "<font color=green>$domain</font><br>";
			elseif($todo)
				print "<font color=gray>$domain</font><br>";
			else
				print "<font color=black>$domain</font><br>";
				

		}


	}
	
}
else
{
?>

<form method=post style="margin-top:30px; margin-left:30px;">
<textarea name=domains style='font-size:20px;width:600px;height:300px;'></textarea>
<br>
<input type="submit"  style='font-size:20px;'>
</form>

<?php
}
?>

</body>
</html>
